package com.tfjybj.itoo.exam.provider.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dmsdbj.itoo.tool.redis.CacheExpire;
import com.tfjybj.itoo.exam.entity.QuestionTypeEntity;
import com.tfjybj.itoo.exam.model.EvaluationTypeModel;
import com.tfjybj.itoo.exam.model.QuestionTypeIdModel;
import com.tfjybj.itoo.exam.model.QuestionTypeModel;
import org.apache.ibatis.annotations.Param;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * QuestionTypeDao接口
 * questionType表
 *
 * @author 郭凯
 * @version 2.0.0
 * @since 2.0.0 2018-11-21 21:10:06
 */
@Repository("questionTypeDao")
public interface QuestionTypeDao extends BaseMapper<QuestionTypeEntity> {

    //region 模板生成：模糊查询

    /**
     * 根据题型名称模糊查询questionType
     *
     * @param questionTypeName 题型名称
     * @return 模糊查询的questionType集合
     * @author 李青松
     * @since 2.0.0 2018-11-01 08:55:53
     */
    List<QuestionTypeEntity> queryLikeQuestionTypeName(@Param("questionTypeName") String questionTypeName);
    //endregion

    /* **********************************以下为非模板生成的内容********************************* */

    @Cacheable(value = "queryAllQuestionType", unless = "#result == null || #result.size()==0")
    @CacheExpire(expire = 600)
    List<QuestionTypeModel> queryAllQuestionType();

    @Cacheable(value = "queryEvaluationAllQuestionType", unless = "#result == null || #result.size()==0")
    @CacheExpire(expire = 600)
    List<EvaluationTypeModel> queryEvaluationAllQuestionType();

    String queryByCode(@Param("code") String code);

    /**
     * 课程练习-根据课程id查询题型
     *
     * @param courseId
     * @return 是否查询成功
     * @author 贾建清
     * @since 2.0.0 2019年3月24日10:37:00
     */
    List<QuestionTypeIdModel> queryQuestionType(@Param("courseId") String courseId);
}
